home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Mesa-2.2 / src / types.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-13  |  41.7 KB  |  1,285 lines

  1. /* $Id: types.h,v 1.19 1997/03/13 03:05:54 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.2
  6.  * Copyright (C) 1995-1997  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: types.h,v $
  26.  * Revision 1.19  1997/03/13 03:05:54  brianp
  27.  * changed AlphaRefInt to AlphaRefUbyte
  28.  *
  29.  * Revision 1.18  1997/03/04 19:17:38  brianp
  30.  * added a few members to gl_texture_image struct
  31.  *
  32.  * Revision 1.17  1997/02/10 19:49:29  brianp
  33.  * added glResizeBuffersMESA() code
  34.  *
  35.  * Revision 1.16  1997/02/09 19:53:43  brianp
  36.  * now use TEXTURE_xD enable constants
  37.  *
  38.  * Revision 1.15  1997/02/09 18:42:41  brianp
  39.  * added GL_EXT_texture3D support
  40.  *
  41.  * Revision 1.14  1997/01/28 22:14:36  brianp
  42.  * now there's separate state for CI and RGBA logic op enabled
  43.  *
  44.  * Revision 1.13  1997/01/21 03:09:41  brianp
  45.  * added definition:  union node;
  46.  *
  47.  * Revision 1.12  1997/01/09 21:26:23  brianp
  48.  * added RefCount to gl_image struct
  49.  *
  50.  * Revision 1.11  1996/12/18 20:01:39  brianp
  51.  * added material bitmask constants and ColorMaterialBitmask
  52.  *
  53.  * Revision 1.10  1996/12/11 20:16:30  brianp
  54.  * changed GLaccum types to signed
  55.  *
  56.  * Revision 1.9  1996/11/08 02:21:04  brianp
  57.  * added NoRaster flag to context
  58.  *
  59.  * Revision 1.8  1996/11/07 04:11:34  brianp
  60.  * now pass gl_image struct pointer to glTexImage[12]D()
  61.  *
  62.  * Revision 1.7  1996/11/06 04:21:58  brianp
  63.  * added Format to struct gl_image
  64.  *
  65.  * Revision 1.6  1996/10/11 03:41:12  brianp
  66.  * removed OffsetBias field
  67.  *
  68.  * Revision 1.5  1996/10/11 00:23:04  brianp
  69.  * changed Polygon/Line/PointZoffset to GLfloat
  70.  *
  71.  * Revision 1.4  1996/09/25 03:22:53  brianp
  72.  * added NO_DRAW_BIT for glDrawBuffer(GL_NONE)
  73.  *
  74.  * Revision 1.3  1996/09/19 03:17:56  brianp
  75.  * removed Window field from struct gl_frame_buffer
  76.  *
  77.  * Revision 1.2  1996/09/15 14:20:54  brianp
  78.  * added GLframebuffer and GLvisual datatypes
  79.  *
  80.  * Revision 1.1  1996/09/13 01:38:16  brianp
  81.  * Initial revision
  82.  *
  83.  */
  84.  
  85.  
  86. #ifndef TYPES_H
  87. #define TYPES_H
  88.  
  89.  
  90. #include "GL/gl.h"
  91. #include "config.h"
  92.  
  93.  
  94.  
  95. /*
  96.  * Accumulation buffer data type:
  97.  */
  98. #if ACCUM_BITS==8
  99.    typedef GLbyte GLaccum;
  100. #elif ACCUM_BITS==16
  101.    typedef GLshort GLaccum;
  102. #else
  103.    illegal number of accumulation bits
  104. #endif
  105.  
  106.  
  107. /*
  108.  * Stencil buffer data type:
  109.  */
  110. #if STENCIL_BITS==8
  111.    typedef GLubyte GLstencil;
  112. #else
  113.    illegal number of stencil bits
  114. #endif
  115.  
  116.  
  117.  
  118. /*
  119.  * Depth buffer data type:
  120.  */
  121. #if DEPTH_BITS==16
  122.    typedef GLushort GLdepth;
  123. #elif DEPTH_BITS==32
  124.    typedef GLint GLdepth;
  125. #else
  126.    illegal number of depth bits
  127. #endif
  128.  
  129.  
  130.  
  131. #include "fixed.h"
  132.  
  133.  
  134.  
  135. typedef struct gl_visual GLvisual;
  136.  
  137. typedef struct gl_context GLcontext;
  138.  
  139. typedef struct gl_frame_buffer GLframebuffer;
  140.  
  141.  
  142.  
  143. /*
  144.  * Point, line and polygon rasterizer functions:
  145.  */
  146. typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last );
  147.  
  148. typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv );
  149.  
  150. typedef void (*polygon_func)( GLcontext *ctx,
  151.                               GLuint n, GLuint vlist[], GLuint pv );
  152.  
  153. typedef void (*triangle_func)( GLcontext *ctx,
  154.                                GLuint v1, GLuint v2, GLuint v3, GLuint pv );
  155.  
  156.  
  157.  
  158.  
  159. /* Generic internal image format */
  160. struct gl_image {
  161.     GLint Width;
  162.     GLint Height;
  163.     GLint Depth;        /* for 3-D texturing */
  164.     GLint Components;    /* 1, 2, 3 or 4 */
  165.         GLenum Format;        /* GL_COLOR_INDEX, GL_RED, GL_RGB, etc */
  166.     GLenum Type;        /* GL_UNSIGNED_BYTE or GL_FLOAT or GL_BITMAP */
  167.     GLvoid *Data;
  168.     GLboolean Interleaved;    /* If TRUE and Format==GL_RGB, GL_RGBA or
  169.                  * GL_LUMINANCE_ALPHA then each row is
  170.                  * stored as RRR..RGGG..GBBB.B instead of
  171.                  * RGBRGBRGBRGB..RGB.  This is only used
  172.                  * for glDrawPixels.
  173.                  */
  174.     GLint RefCount;
  175. };
  176.  
  177.  
  178.  
  179. /* Texture image record */
  180. struct gl_texture_image {
  181.     GLenum Format;        /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
  182.                  * GL_INTENSITY, GL_RGB, or GL_RGBA
  183.                  */
  184.     GLuint Border;        /* 0 or 1 */
  185.     GLuint Width;        /* = 2^WidthLog2 + 2*Border */
  186.     GLuint Height;        /* = 2^HeightLog2 + 2*Border */
  187.     GLuint Depth;        /* = 2^DepthLog2 + 2*Border */
  188.     GLuint Width2;        /* = Width - 2*Border */
  189.     GLuint Height2;        /* = Height - 2*Border */
  190.     GLuint Depth2;        /* = Depth - 2*Border */
  191.     GLuint WidthLog2;    /* = log2(Width2) */
  192.     GLuint HeightLog2;    /* = log2(Height2) */
  193.     GLuint DepthLog2;    /* = log2(Depth2) */
  194.     GLuint MaxLog2;        /* = MAX(WidthLog2, HeightLog2) */
  195.     GLubyte *Data;        /* Image data as unsigned bytes */
  196. };
  197.  
  198.  
  199.  
  200. /*
  201.  * All gl* API functions in api.c jump through pointers in this struct.
  202.  */
  203. struct api_function_table {
  204.    void (*Accum)( GLcontext *, GLenum, GLfloat );
  205.    void (*AlphaFunc)( GLcontext *, GLenum, GLclampf );
  206.    GLboolean (*AreTexturesResident)( GLcontext *, GLsizei,
  207.                                      const GLuint *, GLboolean * );
  208.    void (*ArrayElement)( GLcontext *, GLint );
  209.    void (*Begin)( GLcontext *, GLenum );
  210.    void (*BindTexture)( GLcontext *, GLenum, GLuint );
  211.    void (*Bitmap)( GLcontext *, GLsizei, GLsizei, GLfloat, GLfloat,
  212.              GLfloat, GLfloat, const struct gl_image *bitmap );
  213.    void (*BlendColor)( GLcontext *, GLclampf, GLclampf, GLclampf, GLclampf);
  214.    void (*BlendEquation)( GLcontext *, GLenum );
  215.    void (*BlendFunc)( GLcontext *, GLenum, GLenum );
  216.    void (*CallList)( GLcontext *, GLuint list );
  217.    void (*CallLists)( GLcontext *, GLsizei, GLenum, const GLvoid * );
  218.    void (*Clear)( GLcontext *, GLbitfield );
  219.    void (*ClearAccum)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat );
  220.    void (*ClearColor)( GLcontext *, GLclampf, GLclampf, GLclampf, GLclampf );
  221.    void (*ClearDepth)( GLcontext *, GLclampd );
  222.    void (*ClearIndex)( GLcontext *, GLfloat );
  223.    void (*ClearStencil)( GLcontext *, GLint );
  224.    void (*ClipPlane)( GLcontext *, GLenum, const GLfloat * );
  225.    void (*Color4f)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat );
  226.    void (*Color4ub)( GLcontext *, GLubyte, GLubyte, GLubyte, GLubyte );
  227.    void (*ColorMask)( GLcontext *,
  228.             GLboolean, GLboolean, GLboolean, GLboolean );
  229.    void (*ColorMaterial)( GLcontext *, GLenum, GLenum );
  230.    void (*ColorPointer)( GLcontext *, GLint, GLenum, GLsizei, const GLvoid * );
  231.    void (*CopyPixels)( GLcontext *, GLint, GLint, GLsizei, GLsizei, GLenum );
  232.    void (*CopyTexImage1D)( GLcontext *, GLenum, GLint, GLenum,
  233.                            GLint, GLint, GLsizei, GLint );
  234.    void (*CopyTexImage2D)( GLcontext *, GLenum, GLint, GLenum,
  235.                            GLint, GLint, GLsizei, GLsizei, GLint );
  236.    void (*CopyTexSubImage1D)( GLcontext *, GLenum, GLint, GLint,
  237.                               GLint, GLint, GLsizei );
  238.    void (*CopyTexSubImage2D)( GLcontext *, GLenum, GLint, GLint, GLint,
  239.                               GLint, GLint, GLsizei, GLsizei );
  240.    void (*CopyTexSubImage3DEXT)(GLcontext *,
  241.                                 GLenum , GLint ,
  242.                                 GLint , GLint , GLint ,
  243.                                 GLint , GLint ,
  244.                                 GLsizei , GLsizei  );
  245.    void (*CullFace)( GLcontext *, GLenum );
  246.    void (*DeleteLists)( GLcontext *, GLuint, GLsizei );
  247.    void (*DeleteTextures)( GLcontext *, GLsizei, const GLuint *);
  248.    void (*DepthFunc)( GLcontext *, GLenum );
  249.    void (*DepthMask)( GLcontext *, GLboolean );
  250.    void (*DepthRange)( GLcontext *, GLclampd, GLclampd );
  251.    void (*Disable)( GLcontext *, GLenum );
  252.    void (*DisableClientState)( GLcontext *, GLenum );
  253.    void (*DrawArrays)( GLcontext *, GLenum, GLint, GLsizei );
  254.    void (*DrawBuffer)( GLcontext *, GLenum );
  255.    void (*DrawElements)( GLcontext *, GLenum, GLsizei, GLenum, const GLvoid *);
  256.    void (*DrawPixels)( GLcontext *,
  257.                        GLsizei, GLsizei, GLenum, GLenum, const GLvoid * );
  258.    void (*EdgeFlag)( GLcontext *, GLboolean );
  259.    void (*EdgeFlagPointer)( GLcontext *, GLsizei, const GLboolean * );
  260.    void (*Enable)( GLcontext *, GLenum );
  261.    void (*EnableClientState)( GLcontext *, GLenum );
  262.    void (*End)( GLcontext * );
  263.    void (*EndList)( GLcontext * );
  264.    void (*EvalCoord1f)( GLcontext *, GLfloat );
  265.    void (*EvalCoord2f)( GLcontext *, GLfloat , GLfloat );
  266.    void (*EvalMesh1)( GLcontext *, GLenum, GLint, GLint );
  267.    void (*EvalMesh2)( GLcontext *, GLenum, GLint, GLint, GLint, GLint );
  268.    void (*EvalPoint1)( GLcontext *, GLint );
  269.    void (*EvalPoint2)( GLcontext *, GLint, GLint );
  270.    void (*FeedbackBuffer)( GLcontext *, GLsizei, GLenum, GLfloat * );
  271.    void (*Finish)( GLcontext * );
  272.    void (*Flush)( GLcontext * );
  273.    void (*Fogfv)( GLcontext *, GLenum, const GLfloat * );
  274.    void (*FrontFace)( GLcontext *, GLenum );
  275.    void (*Frustum)( GLcontext *, GLdouble, GLdouble, GLdouble, GLdouble,
  276.               GLdouble, GLdouble );
  277.    GLuint (*GenLists)( GLcontext *, GLsizei );
  278.    void (*GenTextures)( GLcontext *, GLsizei, GLuint * );
  279.    void (*GetBooleanv)( GLcontext *, GLenum, GLboolean * );
  280.    void (*GetClipPlane)( GLcontext *, GLenum, GLdouble * );
  281.    void (*GetDoublev)( GLcontext *, GLenum, GLdouble * );
  282.    GLenum (*GetError)( GLcontext * );
  283.    void (*GetFloatv)( GLcontext *, GLenum, GLfloat * );
  284.    void (*GetIntegerv)( GLcontext *, GLenum, GLint * );
  285.    const GLubyte* (*GetString)( GLcontext *, GLenum name );
  286.    void (*GetLightfv)( GLcontext *, GLenum light, GLenum, GLfloat * );
  287.    void (*GetLightiv)( GLcontext *, GLenum light, GLenum, GLint * );
  288.    void (*GetMapdv)( GLcontext *, GLenum, GLenum, GLdouble * );
  289.    void (*GetMapfv)( GLcontext *, GLenum, GLenum, GLfloat * );
  290.    void (*GetMapiv)( GLcontext *, GLenum, GLenum, GLint * );
  291.    void (*GetMaterialfv)( GLcontext *, GLenum, GLenum, GLfloat * );
  292.    void (*GetMaterialiv)( GLcontext *, GLenum, GLenum, GLint * );
  293.    void (*GetPixelMapfv)( GLcontext *, GLenum, GLfloat * );
  294.    void (*GetPixelMapuiv)( GLcontext *, GLenum, GLuint * );
  295.    void (*GetPixelMapusv)( GLcontext *, GLenum, GLushort * );
  296.    void (*GetPointerv)( GLcontext *, GLenum, GLvoid ** );
  297.    void (*GetPolygonStipple)( GLcontext *, GLubyte * );
  298.    void (*PrioritizeTextures)( GLcontext *, GLsizei, const GLuint *,
  299.                                const GLclampf * );
  300.    void (*GetTexEnvfv)( GLcontext *, GLenum, GLenum, GLfloat * );
  301.    void (*GetTexEnviv)( GLcontext *, GLenum, GLenum, GLint * );
  302.    void (*GetTexGendv)( GLcontext *, GLenum coord, GLenum, GLdouble * );
  303.    void (*GetTexGenfv)( GLcontext *, GLenum coord, GLenum, GLfloat * );
  304.    void (*GetTexGeniv)( GLcontext *, GLenum coord, GLenum, GLint * );
  305.    void (*GetTexImage)( GLcontext *, GLenum, GLint level, GLenum, GLenum,
  306.                         GLvoid * );
  307.    void (*GetTexLevelParameterfv)( GLcontext *,
  308.                      GLenum, GLint, GLenum, GLfloat * );
  309.    void (*GetTexLevelParameteriv)( GLcontext *,
  310.                      GLenum, GLint, GLenum, GLint * );
  311.    void (*GetTexParameterfv)( GLcontext *, GLenum, GLenum, GLfloat *);
  312.    void (*GetTexParameteriv)( GLcontext *, GLenum, GLenum, GLint * );
  313.    void (*Hint)( GLcontext *, GLenum, GLenum );
  314.    void (*IndexMask)( GLcontext *, GLuint );
  315.    void (*Indexf)( GLcontext *, GLfloat c );
  316.    void (*Indexi)( GLcontext *, GLint c );
  317.    void (*IndexPointer)( GLcontext *, GLenum, GLsizei, const GLvoid * );
  318.    void (*InitNames)( GLcontext * );
  319.    void (*InterleavedArrays)( GLcontext *, GLenum, GLsizei, const GLvoid * );
  320.    GLboolean (*IsEnabled)( GLcontext *, GLenum );
  321.    GLboolean (*IsList)( GLcontext *, GLuint );
  322.    GLboolean (*IsTexture)( GLcontext *, GLuint );
  323.    void (*LightModelfv)( GLcontext *, GLenum, const GLfloat * );
  324.    void (*Lightfv)( GLcontext *, GLenum light, GLenum, const GLfloat *, GLint);
  325.    void (*LineStipple)( GLcontext *, GLint factor, GLushort );
  326.    void (*LineWidth)( GLcontext *, GLfloat );
  327.    void (*ListBase)( GLcontext *, GLuint );
  328.    /* LoadIdentity implemented with glLoadMatrixf */
  329.    /* LoadMatrixd implemented with glLoadMatrixf */
  330.    void (*LoadMatrixf)( GLcontext *, const GLfloat * );
  331.    void (*LoadName)( GLcontext *, GLuint );
  332.    void (*LogicOp)( GLcontext *, GLenum );
  333.    void (*Map1f)( GLcontext *, GLenum, GLfloat, GLfloat, GLint, GLint,
  334.           const GLfloat *, GLboolean );
  335.    void (*Map2f)( GLcontext *, GLenum, GLfloat, GLfloat, GLint, GLint,
  336.           GLfloat, GLfloat, GLint, GLint, const GLfloat *,
  337.           GLboolean );
  338.    void (*MapGrid1f)( GLcontext *, GLint, GLfloat, GLfloat );
  339.    void (*MapGrid2f)( GLcontext *, GLint, GLfloat, GLfloat,
  340.             GLint, GLfloat, GLfloat );
  341.    void (*Materialfv)( GLcontext *, GLenum, GLenum, const GLfloat * );
  342.    void (*MatrixMode)( GLcontext *, GLenum );
  343.    /* MultMatrixd implemented with glMultMatrixf */
  344.    void (*MultMatrixf)( GLcontext *, const GLfloat * );
  345.    void (*NewList)( GLcontext *, GLuint list, GLenum );
  346.    void (*Normal3f)( GLcontext *, GLfloat, GLfloat, GLfloat );
  347.    void (*Normal3fv)( GLcontext *, const GLfloat * );
  348.    void (*NormalPointer)( GLcontext *, GLenum, GLsizei, const GLvoid * );
  349.    /* Ortho implemented with MultMatrixf */
  350.    void (*PassThrough)( GLcontext *, GLfloat );
  351.    void (*PixelMapfv)( GLcontext *, GLenum, GLint, const GLfloat * );
  352.    void (*PixelStorei)( GLcontext *, GLenum, GLint );
  353.    void (*PixelTransferf)( GLcontext *, GLenum, GLfloat );
  354.    void (*PixelZoom)( GLcontext *, GLfloat, GLfloat );
  355.    void (*PointSize)( GLcontext *, GLfloat );
  356.    void (*PolygonMode)( GLcontext *, GLenum, GLenum );
  357.    void (*PolygonOffset)( GLcontext *, GLfloat, GLfloat );
  358.    void (*PolygonStipple)( GLcontext *, const GLubyte * );
  359.    void (*PopAttrib)( GLcontext * );
  360.    void (*PopClientAttrib)( GLcontext * );
  361.    void (*PopMatrix)( GLcontext * );
  362.    void (*PopName)( GLcontext * );
  363.    void (*PushAttrib)( GLcontext *, GLbitfield );
  364.    void (*PushClientAttrib)( GLcontext *, GLbitfield );
  365.    void (*PushMatrix)( GLcontext * );
  366.    void (*PushName)( GLcontext *, GLuint );
  367.    void (*RasterPos4f)( GLcontext *,
  368.                         GLfloat x, GLfloat y, GLfloat z, GLfloat w );
  369.    void (*ReadBuffer)( GLcontext *, GLenum );
  370.    void (*ReadPixels)( GLcontext *, GLint, GLint, GLsizei, GLsizei, GLenum,
  371.              GLenum, GLvoid * );
  372.    void (*Rectf)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat );
  373.    GLint (*RenderMode)( GLcontext *, GLenum );
  374.    void (*Rotatef)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat );
  375.    void (*Scalef)( GLcontext *, GLfloat, GLfloat, GLfloat );
  376.    void (*Scissor)( GLcontext *, GLint, GLint, GLsizei, GLsizei);
  377.    void (*SelectBuffer)( GLcontext *, GLsizei, GLuint * );
  378.    void (*ShadeModel)( GLcontext *, GLenum );
  379.    void (*StencilFunc)( GLcontext *, GLenum, GLint, GLuint );
  380.    void (*StencilMask)( GLcontext *, GLuint );
  381.    void (*StencilOp)( GLcontext *, GLenum, GLenum, GLenum );
  382.    void (*TexCoord4f)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat );
  383.    void (*TexCoordPointer)( GLcontext *, GLint, GLenum, GLsizei,
  384.                             const GLvoid *);
  385.    void (*TexEnvfv)( GLcontext *, GLenum, GLenum, const GLfloat * );
  386.    void (*TexGenfv)( GLcontext *, GLenum coord, GLenum, const GLfloat * );
  387.    void (*TexImage1D)( GLcontext *, GLenum, GLint, GLint, GLsizei,
  388.                        GLint, GLenum, GLenum, struct gl_image * );
  389.    void (*TexImage2D)( GLcontext *, GLenum, GLint, GLint, GLsizei, GLsizei,
  390.                        GLint, GLenum, GLenum, struct gl_image * );
  391.    void (*TexSubImage1D)( GLcontext *, GLenum, GLint, GLint, GLsizei,
  392.                           GLenum, GLenum, struct gl_image * );
  393.    void (*TexSubImage2D)( GLcontext *, GLenum, GLint, GLint, GLint,
  394.                           GLsizei, GLsizei, GLenum, GLenum,
  395.                           struct gl_image * );
  396.    void (*TexImage3DEXT)(GLcontext *,
  397.                          GLenum , GLint , GLint ,
  398.                          GLsizei , GLsizei , GLsizei ,
  399.                          GLint ,
  400.                          GLenum , GLenum ,
  401.                          struct gl_image * );
  402.    void (*TexSubImage3DEXT)(GLcontext *,
  403.                             GLenum , GLint ,
  404.                             GLint , GLint , GLint,
  405.                             GLsizei , GLsizei , GLsizei ,
  406.                             GLenum , GLenum ,
  407.                             struct gl_image * );
  408.    void (*TexParameterfv)( GLcontext *, GLenum, GLenum, const GLfloat * );
  409.    /* Translated implemented by Translatef */
  410.    void (*Translatef)( GLcontext *, GLfloat, GLfloat, GLfloat );
  411.    void (*Vertex4f)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat );
  412.    void (*VertexPointer)( GLcontext *, GLint, GLenum, GLsizei, const GLvoid *);
  413.    void (*Viewport)( GLcontext *, GLint, GLint, GLsizei, GLsizei );
  414.  
  415.    /* GL_MESA_window_pos extension */
  416.    void (*WindowPos4fMESA)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat );
  417.  
  418.    /* GL_MESA_resize_buffers extension */
  419.    void (*ResizeBuffersMESA)( GLcontext * );
  420. };
  421.  
  422.  
  423.  
  424. #include "dd.h"
  425.  
  426.  
  427. /*
  428.  * Bit flags used for updating material values.
  429.  */
  430. #define FRONT_AMBIENT_BIT     0x1
  431. #define BACK_AMBIENT_BIT      0x2
  432. #define FRONT_DIFFUSE_BIT     0x4
  433. #define BACK_DIFFUSE_BIT      0x8
  434. #define FRONT_SPECULAR_BIT   0x10
  435. #define BACK_SPECULAR_BIT    0x20
  436. #define FRONT_EMISSION_BIT   0x40
  437. #define BACK_EMISSION_BIT    0x80
  438. #define FRONT_SHININESS_BIT 0x100
  439. #define BACK_SHININESS_BIT  0x200
  440. #define FRONT_INDEXES_BIT   0x400
  441. #define BACK_INDEXES_BIT    0x800
  442.  
  443. #define FRONT_MATERIAL_BITS    (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT | \
  444.                  FRONT_DIFFUSE_BIT | FRONT_SPECULAR_BIT | \
  445.                  FRONT_SHININESS_BIT | FRONT_INDEXES_BIT)
  446.  
  447. #define BACK_MATERIAL_BITS    (BACK_EMISSION_BIT | BACK_AMBIENT_BIT | \
  448.                  BACK_DIFFUSE_BIT | BACK_SPECULAR_BIT | \
  449.                  BACK_SHININESS_BIT | BACK_INDEXES_BIT)
  450.  
  451. #define ALL_MATERIAL_BITS    (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
  452.  
  453.  
  454.  
  455. /*
  456.  * Specular exponent and material shininess lookup table sizes:
  457.  */
  458. #define EXP_TABLE_SIZE 512
  459. #define SHINE_TABLE_SIZE 200
  460.  
  461. struct gl_light {
  462.     GLfloat Ambient[4];        /* ambient color */
  463.     GLfloat Diffuse[4];        /* diffuse color */
  464.     GLfloat Specular[4];        /* specular color */
  465.     GLfloat Position[4];        /* position in eye coordinates */
  466.     GLfloat Direction[4];        /* spotlight dir in eye coordinates */
  467.     GLfloat SpotExponent;
  468.     GLfloat SpotCutoff;        /* in degress */
  469.         GLfloat CosCutoff;        /* = cos(SpotCutoff) */
  470.     GLfloat ConstantAttenuation;
  471.     GLfloat LinearAttenuation;
  472.     GLfloat QuadraticAttenuation;
  473.     GLboolean Enabled;        /* On/off flag */
  474.  
  475.     struct gl_light *NextEnabled;    /* Ptr to next enabled light or NULL */
  476.  
  477.     /* Derived fields */
  478.     GLfloat VP_inf_norm[3];        /* Norm direction to infinite light */
  479.     GLfloat h_inf_norm[3];        /* Norm( VP_inf_norm + <0,0,1> ) */
  480.         GLfloat NormDirection[3];    /* normalized spotlight direction */
  481.         GLfloat SpotExpTable[EXP_TABLE_SIZE][2];  /* to replace a pow() call */
  482.     GLfloat MatAmbient[3];        /* front mat ambient * light ambient */
  483.     GLfloat MatDiffuse[3];        /* front mat diffuse * light diffuse */
  484.     GLfloat MatSpecular[3];        /* front mat spec * light specular */
  485.     GLfloat dli;            /* CI diffuse light intensity */
  486.     GLfloat sli;            /* CI specular light intensity */
  487. };
  488.  
  489.  
  490. struct gl_lightmodel {
  491.     GLfloat Ambient[4];        /* ambient color */
  492.     GLboolean LocalViewer;        /* Local (or infinite) view point? */
  493.     GLboolean TwoSide;        /* Two (or one) sided lighting? */
  494. };
  495.  
  496.  
  497. struct gl_material {
  498.     GLfloat Ambient[4];
  499.     GLfloat Diffuse[4];
  500.     GLfloat Specular[4];
  501.     GLfloat Emission[4];
  502.     GLfloat Shininess;
  503.     GLfloat AmbientIndex;    /* for color index lighting */
  504.     GLfloat DiffuseIndex;    /* for color index lighting */
  505.     GLfloat SpecularIndex;    /* for color index lighting */
  506.         GLfloat ShineTable[SHINE_TABLE_SIZE];  /* to replace a pow() call */
  507. };
  508.  
  509.  
  510.  
  511. /*
  512.  * Attribute structures:
  513.  *    We define a struct for each attribute group to make pushing and
  514.  *    popping attributes easy.  Also it's a good organization.
  515.  */
  516.  
  517.  
  518. struct gl_accum_attrib {
  519.     GLfloat ClearColor[4];    /* Accumulation buffer clear color */
  520. };
  521.  
  522.  
  523. struct gl_colorbuffer_attrib {
  524.     GLuint ClearIndex;        /* Index to use for glClear */
  525.     GLfloat ClearColor[4];        /* Color to use for glClear */
  526.  
  527.     GLuint IndexMask;        /* Color index write mask */
  528.     GLuint ColorMask;        /* bit 3=red,2=green,1=blue,0=alpha*/
  529.         GLboolean SWmasking;        /* Do color/CI masking in software? */
  530.  
  531.     GLenum DrawBuffer;        /* Which buffer to draw into */
  532.  
  533.     /* alpha testing */
  534.     GLboolean AlphaEnabled;        /* Alpha test enabled flag */
  535.     GLenum AlphaFunc;        /* Alpha test function */
  536.     GLfloat AlphaRef;        /* Alpha reference value */
  537.     GLubyte AlphaRefUbyte;        /* AlphaRef scaled to an integer */
  538.  
  539.     /* blending */
  540.     GLboolean BlendEnabled;        /* Blending enabled flag */
  541.     GLenum BlendSrc;        /* Blending source operator */
  542.     GLenum BlendDst;        /* Blending destination operator */
  543.     GLenum BlendEquation;
  544.     GLfloat BlendColor[4];
  545.  
  546.     /* logic op */
  547.     GLenum LogicOp;            /* Logic operator */
  548.     GLboolean IndexLogicOpEnabled;    /* Color index logic op enabled flag */
  549.     GLboolean ColorLogicOpEnabled;    /* RGBA logic op enabled flag */
  550.     GLboolean SWLogicOpEnabled;    /* Do logic ops in software? */
  551.  
  552.     GLboolean DitherFlag;        /* Dither enable flag */
  553. };
  554.  
  555.  
  556. struct gl_current_attrib {
  557.     GLint IntColor[4];        /* Current RGBA color as scaled ints*/
  558.     GLuint Index;            /* Current color index */
  559.     GLfloat Normal[3];        /* Current normal vector */
  560.     GLfloat TexCoord[4];        /* Current texture coordinate */
  561.     GLfloat RasterPos[4];        /* Current raster position */
  562.     GLfloat RasterDistance;        /* Current raster distance */
  563.     GLfloat RasterColor[4];        /* Current raster color */
  564.     GLuint RasterIndex;        /* Current raster index */
  565.     GLfloat RasterTexCoord[4];    /* Current raster texture coord */
  566.     GLboolean RasterPosValid;    /* Raster position valid flag */
  567.     GLboolean EdgeFlag;        /* Current edge flag */
  568. };
  569.  
  570.  
  571. struct gl_depthbuffer_attrib {
  572.     GLenum Func;        /* Function for depth buffer compare */
  573.     GLfloat Clear;        /* Value to clear depth buffer to */
  574.     GLboolean Test;        /* Depth buffering enabled flag */
  575.     GLboolean Mask;        /* Depth buffer writable? */
  576. };
  577.  
  578.  
  579. struct gl_enable_attrib {
  580.     GLboolean AlphaTest;
  581.     GLboolean AutoNormal;
  582.     GLboolean Blend;
  583.     GLboolean ClipPlane[MAX_CLIP_PLANES];
  584.     GLboolean ColorMaterial;
  585.     GLboolean CullFace;
  586.     GLboolean DepthTest;
  587.     GLboolean Dither;
  588.     GLboolean Fog;
  589.     GLboolean Light[MAX_LIGHTS];
  590.     GLboolean Lighting;
  591.     GLboolean LineSmooth;
  592.     GLboolean LineStipple;
  593.     GLboolean IndexLogicOp;
  594.     GLboolean ColorLogicOp;
  595.     GLboolean Map1Color4;
  596.     GLboolean Map1Index;
  597.     GLboolean Map1Normal;
  598.     GLboolean Map1TextureCoord1;
  599.     GLboolean Map1TextureCoord2;
  600.     GLboolean Map1TextureCoord3;
  601.     GLboolean Map1TextureCoord4;
  602.     GLboolean Map1Vertex3;
  603.     GLboolean Map1Vertex4;
  604.     GLboolean Map2Color4;
  605.     GLboolean Map2Index;
  606.     GLboolean Map2Normal;
  607.     GLboolean Map2TextureCoord1;
  608.     GLboolean Map2TextureCoord2;
  609.     GLboolean Map2TextureCoord3;
  610.     GLboolean Map2TextureCoord4;
  611.     GLboolean Map2Vertex3;
  612.     GLboolean Map2Vertex4;
  613.     GLboolean Normalize;
  614.     GLboolean PointSmooth;
  615.     GLboolean PolygonOffsetPoint;
  616.     GLboolean PolygonOffsetLine;
  617.     GLboolean PolygonOffsetFill;
  618.     GLboolean PolygonSmooth;
  619.     GLboolean PolygonStipple;
  620.     GLboolean Scissor;
  621.     GLboolean Stencil;
  622.     GLuint Texture;
  623.     GLuint TexGen;
  624. };
  625.  
  626.  
  627. struct gl_eval_attrib {
  628.     /* Enable bits */
  629.     GLboolean Map1Color4;
  630.     GLboolean Map1Index;
  631.     GLboolean Map1Normal;
  632.     GLboolean Map1TextureCoord1;
  633.     GLboolean Map1TextureCoord2;
  634.     GLboolean Map1TextureCoord3;
  635.     GLboolean Map1TextureCoord4;
  636.     GLboolean Map1Vertex3;
  637.     GLboolean Map1Vertex4;
  638.     GLboolean Map2Color4;
  639.     GLboolean Map2Index;
  640.     GLboolean Map2Normal;
  641.     GLboolean Map2TextureCoord1;
  642.     GLboolean Map2TextureCoord2;
  643.     GLboolean Map2TextureCoord3;
  644.     GLboolean Map2TextureCoord4;
  645.     GLboolean Map2Vertex3;
  646.     GLboolean Map2Vertex4;
  647.     GLboolean AutoNormal;
  648.     /* Map Grid endpoints and divisions */
  649.     GLuint MapGrid1un;
  650.     GLfloat MapGrid1u1, MapGrid1u2;
  651.     GLuint MapGrid2un, MapGrid2vn;
  652.     GLfloat MapGrid2u1, MapGrid2u2;
  653.     GLfloat MapGrid2v1, MapGrid2v2;
  654. };
  655.  
  656.  
  657. struct gl_fog_attrib {
  658.     GLboolean Enabled;        /* Fog enabled flag */
  659.     GLfloat Color[4];        /* Fog color */
  660.     GLfloat Density;        /* Density >= 0.0 */
  661.     GLfloat Start;            /* Start distance in eye coords */
  662.     GLfloat End;            /* End distance in eye coords */
  663.     GLfloat Index;            /* Fog index */
  664.     GLenum Mode;            /* Fog mode */
  665. };
  666.  
  667.  
  668. struct gl_hint_attrib {
  669.     /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */
  670.     GLenum PerspectiveCorrection;
  671.     GLenum PointSmooth;
  672.     GLenum LineSmooth;
  673.     GLenum PolygonSmooth;
  674.     GLenum Fog;
  675. };
  676.  
  677.  
  678. struct gl_light_attrib {
  679.    struct gl_light Light[MAX_LIGHTS];    /* Array of lights */
  680.    struct gl_lightmodel Model;        /* Lighting model */
  681.    struct gl_material Material[2];    /* Material 0=front, 1=back */
  682.    GLboolean Enabled;            /* Lighting enabled flag */
  683.    GLenum ShadeModel;            /* GL_FLAT or GL_SMOOTH */
  684.    GLenum ColorMaterialFace;        /* GL_FRONT, BACK or FRONT_AND_BACK */
  685.    GLenum ColorMaterialMode;        /* GL_AMBIENT, GL_DIFFUSE, etc */
  686.    GLuint ColorMaterialBitmask;        /* bitmask formed from Face and Mode */
  687.    GLboolean ColorMaterialEnabled;
  688.  
  689.    /* Derived for optimizations: */
  690.    struct gl_light *FirstEnabled;    /* Ptr to 1st enabled light */
  691.    GLboolean Fast;            /* Use fast shader? */
  692.    GLfloat BaseColor[4];
  693. };
  694.  
  695.  
  696. struct gl_line_attrib {
  697.     GLboolean SmoothFlag;        /* GL_LINE_SMOOTH enabled? */
  698.     GLboolean StippleFlag;        /* GL_LINE_STIPPLE enabled? */
  699.     GLushort StipplePattern;    /* Stipple pattern */
  700.     GLint StippleFactor;        /* Stipple repeat factor */
  701.     GLfloat Width;            /* Line width */
  702. };
  703.  
  704.  
  705. struct gl_list_attrib {
  706.     GLuint ListBase;
  707. };
  708.  
  709.  
  710. struct gl_pixel_attrib {
  711.     GLenum ReadBuffer;
  712.     GLfloat RedBias, RedScale;    /* Pixel xfer bias & scale values */
  713.     GLfloat GreenBias, GreenScale;
  714.     GLfloat BlueBias, BlueScale;
  715.     GLfloat AlphaBias, AlphaScale;
  716.     GLfloat DepthBias, DepthScale;
  717.     GLint IndexShift;
  718.     GLint IndexOffset;
  719.     GLboolean MapColorFlag;
  720.     GLboolean MapStencilFlag;
  721.     GLfloat ZoomX;            /* Pixel zoom X factor */
  722.     GLfloat ZoomY;            /* Pixel zoom Y factor */
  723.     /* TODO: Do the following belong here??? */
  724.     GLint MapStoSsize;            /* Size of each pixel map */
  725.     GLint MapItoIsize;
  726.     GLint MapItoRsize;
  727.     GLint MapItoGsize;
  728.     GLint MapItoBsize;
  729.     GLint MapItoAsize;
  730.     GLint MapRtoRsize;
  731.     GLint MapGtoGsize;
  732.     GLint MapBtoBsize;
  733.     GLint MapAtoAsize;
  734.     GLint MapStoS[MAX_PIXEL_MAP_TABLE];    /* Pixel map tables */
  735.     GLint MapItoI[MAX_PIXEL_MAP_TABLE];
  736.     GLfloat MapItoR[MAX_PIXEL_MAP_TABLE];
  737.     GLfloat MapItoG[MAX_PIXEL_MAP_TABLE];
  738.     GLfloat MapItoB[MAX_PIXEL_MAP_TABLE];
  739.     GLfloat MapItoA[MAX_PIXEL_MAP_TABLE];
  740.     GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE];
  741.     GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE];
  742.     GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE];
  743.     GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE];
  744. };
  745.  
  746.  
  747. struct gl_point_attrib {
  748.     GLboolean SmoothFlag;    /* True if GL_POINT_SMOOTH is enabled */
  749.     GLfloat Size;        /* Point size */
  750. };
  751.  
  752.  
  753. struct gl_polygon_attrib {
  754.     GLenum FrontFace;    /* Either GL_CW or GL_CCW */
  755.     GLenum FrontMode;    /* Either GL_POINT, GL_LINE or GL_FILL */
  756.     GLenum BackMode;    /* Either GL_POINT, GL_LINE or GL_FILL */
  757.     GLboolean Unfilled;    /* True if back or front mode is not GL_FILL */
  758.     GLboolean CullFlag;    /* Culling on/off flag */
  759.     GLenum CullFaceMode;    /* Culling mode GL_FRONT or GL_BACK */
  760.         GLuint CullBits;    /* Used for cull testing */
  761.     GLboolean SmoothFlag;    /* True if GL_POLYGON_SMOOTH is enabled */
  762.     GLboolean StippleFlag;    /* True if GL_POLYGON_STIPPLE is enabled */
  763.         GLfloat OffsetFactor;    /* Polygon offset factor */
  764.         GLfloat OffsetUnits;    /* Polygon offset units */
  765.         GLboolean OffsetPoint;    /* Offset in GL_POINT mode? */
  766.         GLboolean OffsetLine;    /* Offset in GL_LINE mode? */
  767.         GLboolean OffsetFill;    /* Offset in GL_FILL mode? */
  768.         GLboolean OffsetAny;    /* OR of OffsetPoint, OffsetLine, OffsetFill */
  769. };
  770.  
  771.  
  772. struct gl_scissor_attrib {
  773.     GLboolean    Enabled;        /* Scissor test enabled? */
  774.     GLint        X, Y;            /* Lower left corner of box */
  775.     GLsizei        Width, Height;        /* Size of box */
  776. };
  777.  
  778.  
  779. struct gl_stencil_attrib {
  780.     GLboolean    Enabled;    /* Enabled flag */
  781.     GLenum        Function;    /* Stencil function */
  782.     GLenum        FailFunc;    /* Fail function */
  783.     GLenum        ZPassFunc;    /* Depth buffer pass function */
  784.     GLenum        ZFailFunc;    /* Depth buffer fail function */
  785.     GLstencil    Ref;        /* Reference value */
  786.     GLstencil    ValueMask;    /* Value mask */
  787.     GLstencil    Clear;        /* Clear value */
  788.     GLstencil    WriteMask;    /* Write mask */
  789. };
  790.  
  791.  
  792. #define Q_BIT 1
  793. #define R_BIT 2
  794. #define S_BIT 4
  795. #define T_BIT 8
  796.  
  797. #define TEXTURE_1D 1
  798. #define TEXTURE_2D 2
  799. #define TEXTURE_3D 4
  800.  
  801.  
  802. struct gl_texture_attrib {
  803.     GLuint Enabled;            /* Bitwise-OR of TEXTURE_XD values */
  804.     GLenum EnvMode;            /* GL_MODULATE, GL_DECAL, GL_BLEND */
  805.     GLfloat EnvColor[4];
  806.     GLuint TexGenEnabled;        /* Bitwise-OR of [QRST]_BIT values */
  807.     GLenum GenModeS;        /* Tex coord generation mode, either */
  808.     GLenum GenModeT;        /*    GL_OBJECT_LINEAR, or */
  809.     GLenum GenModeR;        /*    GL_EYE_LINEAR, or    */
  810.     GLenum GenModeQ;        /*      GL_SPHERE_MAP        */
  811.     GLfloat ObjectPlaneS[4];
  812.     GLfloat ObjectPlaneT[4];
  813.     GLfloat ObjectPlaneR[4];
  814.     GLfloat ObjectPlaneQ[4];
  815.     GLfloat EyePlaneS[4];
  816.     GLfloat EyePlaneT[4];
  817.     GLfloat EyePlaneR[4];
  818.     GLfloat EyePlaneQ[4];
  819.     struct gl_texture_object *Current1D;
  820.     struct gl_texture_object *Current2D;
  821.     struct gl_texture_object *Current3D;
  822. #ifdef GL_VERSION_1_1
  823.     struct gl_texture_object *Proxy1D;
  824.     struct gl_texture_object *Proxy2D;
  825.     struct gl_texture_object *Proxy3D;
  826. #endif
  827. };
  828.  
  829.  
  830. struct gl_transform_attrib {
  831.     GLenum MatrixMode;            /* Matrix mode */
  832.     GLfloat ClipEquation[MAX_CLIP_PLANES][4];
  833.     GLboolean ClipEnabled[MAX_CLIP_PLANES];
  834.     GLboolean AnyClip;            /* Any ClipEnabled[] true? */
  835.     GLboolean Normalize;            /* Normalize all normals? */
  836. };
  837.  
  838.  
  839. struct gl_viewport_attrib {
  840.     GLint X, Y;        /* position */
  841.     GLsizei Width, Height;    /* size */
  842.     GLfloat Near, Far;    /* Depth buffer range */
  843.     GLfloat Sx, Sy, Sz;    /* NDC to WinCoord scaling */
  844.     GLfloat Tx, Ty, Tz;    /* NDC to WinCoord translation */
  845. };
  846.  
  847.  
  848. /* For the attribute stack: */
  849. struct gl_attrib_node {
  850.     GLbitfield kind;
  851.     void *data;
  852.     struct gl_attrib_node *next;
  853. };
  854.  
  855.  
  856.  
  857. /*
  858.  * Client pixel packing/unpacking attributes
  859.  */
  860. struct gl_pixelstore_attrib {
  861.     GLint Alignment;
  862.     GLint RowLength;
  863.     GLint SkipPixels;
  864.     GLint SkipRows;
  865.     GLint ImageHeight;     /* for GL_EXT_texture3D */
  866.     GLint SkipImages;      /* for GL_EXT_texture3D */
  867.     GLboolean SwapBytes;
  868.     GLboolean LsbFirst;
  869. };
  870.  
  871.  
  872. /*
  873.  * Client vertex array attributes
  874.  */
  875. struct gl_array_attrib {
  876.     GLint VertexSize;
  877.     GLenum VertexType;
  878.     GLsizei VertexStride;        /* user-specified stride */
  879.     GLsizei VertexStrideB;        /* actual stride in bytes */
  880.     void *VertexPtr;
  881.     GLboolean VertexEnabled;
  882.  
  883.     GLenum NormalType;
  884.     GLsizei NormalStride;        /* user-specified stride */
  885.     GLsizei NormalStrideB;        /* actual stride in bytes */
  886.     void *NormalPtr;
  887.     GLboolean NormalEnabled;
  888.  
  889.     GLint ColorSize;
  890.     GLenum ColorType;
  891.     GLsizei ColorStride;        /* user-specified stride */
  892.     GLsizei ColorStrideB;        /* actual stride in bytes */
  893.     void *ColorPtr;
  894.     GLboolean ColorEnabled;
  895.  
  896.     GLenum IndexType;
  897.     GLsizei IndexStride;        /* user-specified stride */
  898.     GLsizei IndexStrideB;        /* actual stride in bytes */
  899.     void *IndexPtr;
  900.     GLboolean IndexEnabled;
  901.  
  902.     GLint TexCoordSize;
  903.     GLenum TexCoordType;
  904.     GLsizei TexCoordStride;        /* user-specified stride */
  905.     GLsizei TexCoordStrideB;    /* actual stride in bytes */
  906.     void *TexCoordPtr;
  907.     GLboolean TexCoordEnabled;
  908.  
  909.     GLsizei EdgeFlagStride;        /* user-specified stride */
  910.     GLsizei EdgeFlagStrideB;    /* actual stride in bytes */
  911.     GLboolean *EdgeFlagPtr;
  912.     GLboolean EdgeFlagEnabled;
  913. };
  914.  
  915.  
  916.  
  917. struct gl_feedback {
  918.     GLenum Type;
  919.     GLuint Mask;
  920.     GLfloat *Buffer;
  921.     GLuint BufferSize;
  922.     GLuint Count;
  923. };
  924.  
  925.  
  926.  
  927. struct gl_selection {
  928.     GLuint *Buffer;
  929.     GLuint BufferSize;    /* size of SelectBuffer */
  930.     GLuint BufferCount;    /* number of values in SelectBuffer */
  931.     GLuint Hits;        /* number of records in SelectBuffer */
  932.     GLuint NameStackDepth;
  933.     GLuint NameStack[MAX_NAME_STACK_DEPTH];
  934.     GLboolean HitFlag;
  935.     GLfloat HitMinZ, HitMaxZ;
  936. };
  937.  
  938.  
  939.  
  940. /*
  941.  * 1-D Evaluator control points
  942.  */
  943. struct gl_1d_map {
  944.     GLuint Order;        /* Number of control points */
  945.     GLfloat u1, u2;
  946.     GLfloat *Points;    /* Points to contiguous control points */
  947.     GLboolean Retain;    /* Reference counter */
  948. };
  949.     
  950.  
  951. /*
  952.  * 2-D Evaluator control points
  953.  */
  954. struct gl_2d_map {
  955.     GLuint Uorder;        /* Number of control points in U dimension */
  956.     GLuint Vorder;        /* Number of control points in V dimension */
  957.     GLfloat u1, u2;
  958.     GLfloat v1, v2;
  959.     GLfloat *Points;    /* Points to contiguous control points */
  960.     GLboolean Retain;    /* Reference counter */
  961. };
  962.  
  963.  
  964. /*
  965.  * All evalutator control points
  966.  */
  967. struct gl_evaluators {
  968.     /* 1-D maps */
  969.     struct gl_1d_map Map1Vertex3;
  970.     struct gl_1d_map Map1Vertex4;
  971.     struct gl_1d_map Map1Index;
  972.     struct gl_1d_map Map1Color4;
  973.     struct gl_1d_map Map1Normal;
  974.     struct gl_1d_map Map1Texture1;
  975.     struct gl_1d_map Map1Texture2;
  976.     struct gl_1d_map Map1Texture3;
  977.     struct gl_1d_map Map1Texture4;
  978.  
  979.     /* 2-D maps */
  980.     struct gl_2d_map Map2Vertex3;
  981.     struct gl_2d_map Map2Vertex4;
  982.     struct gl_2d_map Map2Index;
  983.     struct gl_2d_map Map2Color4;
  984.     struct gl_2d_map Map2Normal;
  985.     struct gl_2d_map Map2Texture1;
  986.     struct gl_2d_map Map2Texture2;
  987.     struct gl_2d_map Map2Texture3;
  988.     struct gl_2d_map Map2Texture4;
  989. };
  990.  
  991.  
  992.  
  993. /* Texture object record */
  994. struct gl_texture_object {
  995.     GLint RefCount;            /* reference count */
  996.     GLuint Name;            /* an unsigned integer */
  997.     GLuint Dimensions;        /* 1 or 2 or 3 */
  998.     GLfloat Priority;        /* in [0,1] */
  999.     GLint BorderColor[4];        /* as integers in [0,255] */
  1000.     GLenum WrapS;            /* GL_CLAMP or GL_REPEAT */
  1001.     GLenum WrapT;            /* GL_CLAMP or GL_REPEAT */
  1002.     GLenum WrapR;            /* GL_CLAMP or GL_REPEAT */
  1003.     GLenum MinFilter;        /* minification filter */
  1004.     GLenum MagFilter;        /* magnification filter */
  1005.     struct gl_texture_image *Image[MAX_TEXTURE_LEVELS];
  1006.     GLboolean Complete;        /* Complete set of images? */
  1007.     struct gl_texture_object *Next;    /* Next in linked list */
  1008. };
  1009.  
  1010.  
  1011. /*
  1012.  * Display list building block:
  1013.  */
  1014. union node;
  1015.  
  1016.  
  1017. /*
  1018.  * State possibly shared by multiple contexts:
  1019.  */
  1020. struct gl_shared_state {
  1021.     GLint RefCount;                /* Reference count */
  1022.     union node *List[MAX_DISPLAYLISTS];    /* Display lists */
  1023.     struct gl_texture_object *TexObjectList;/* Texture objects */
  1024. };
  1025.  
  1026.  
  1027.  
  1028. /* Display list info shared by multiple contexts: */
  1029. struct gl_list_group {
  1030.     union node *List[MAX_DISPLAYLISTS];    /* The display lists */
  1031.     GLint RefCount;                /* Reference count */
  1032. };
  1033.  
  1034.  
  1035.  
  1036.  
  1037. /*
  1038.  * Describes the color, depth, stencil and accum buffer parameters.
  1039.  */
  1040. struct gl_visual {
  1041.     GLboolean RGBAflag;    /* Is frame buffer in RGBA mode, not CI? */
  1042.     GLboolean DBflag;    /* Is color buffer double buffered? */
  1043.  
  1044.     GLfloat RedScale;    /* These values are used to scale color */
  1045.     GLfloat GreenScale;    /* components from the range [0,1] to */
  1046.     GLfloat BlueScale;    /* integer values.  It should be the case */
  1047.     GLfloat AlphaScale;    /* that scale = 2^bits - 1 where bits is */
  1048.                 /* the number of bits for the component */
  1049.                 /* in the frame buffer. */
  1050.     GLboolean EightBitColor;/* TRUE if all the above scales are 255.0 */
  1051.  
  1052.  
  1053.         GLfloat InvRedScale;    /* = 1 / RedScale */
  1054.         GLfloat InvGreenScale;    /* = 1 / GreenScale */
  1055.         GLfloat InvBlueScale;    /* = 1 / BlueScale */
  1056.         GLfloat InvAlphaScale;    /* = 1 / AlphaScale */
  1057.  
  1058.     GLint IndexBits;    /* Bits/pixel if in color index mode */
  1059.  
  1060.     GLint AccumBits;    /* Number of bits per color channel, or 0 */
  1061.     GLint DepthBits;    /* Number of bits in depth buffer, or 0 */
  1062.     GLint StencilBits;    /* Number of bits in stencil buffer, or 0 */
  1063.  
  1064.     /* Software alpha planes: */
  1065.     GLboolean FrontAlphaEnabled;
  1066.     GLboolean BackAlphaEnabled;
  1067. };
  1068.  
  1069.  
  1070.  
  1071. /*
  1072.  * A "frame buffer" is a color buffer and its optional ancillary buffers:
  1073.  * depth, accum, stencil, and software-simulated alpha buffers.
  1074.  */
  1075. struct gl_frame_buffer {
  1076.     GLvisual *Visual;    /* The corresponding visual */
  1077.  
  1078.     GLint Width;        /* Width of frame buffer in pixels */
  1079.     GLint Height;        /* Height of frame buffer in pixels */
  1080.  
  1081.     GLdepth *Depth;        /* array [Width*Height] of GLdepth values */
  1082.  
  1083.     /* Stencil buffer */
  1084.     GLstencil *Stencil;    /* array [Width*Height] of GLstencil values */
  1085.  
  1086.     /* Accumulation buffer */
  1087.     GLaccum *Accum;        /* array [4*Width*Height] of GLaccum values */
  1088.  
  1089.     /* Software alpha planes: */
  1090.     GLubyte *FrontAlpha;    /* array [Width*Height] of GLubyte */
  1091.     GLubyte *BackAlpha;    /* array [Width*Height] of GLubyte */
  1092.     GLubyte *Alpha;        /* Points to front or back alpha buffer */
  1093.  
  1094.     /* Drawing bounds: intersection of window size and scissor box */
  1095.     GLint Xmin, Xmax, Ymin, Ymax;
  1096. #if 0
  1097.         /* For linked list: */
  1098.         struct gl_frame_buffer *Next;
  1099. #endif
  1100. };
  1101.  
  1102.  
  1103.  
  1104. /*
  1105.  * Bitmasks to indicate what auxillary information must be interpolated
  1106.  * when clipping (CC.ClipMask).
  1107.  */
  1108. #define CLIP_FCOLOR_BIT        0x01
  1109. #define CLIP_BCOLOR_BIT        0x02
  1110. #define CLIP_FINDEX_BIT        0x04
  1111. #define CLIP_BINDEX_BIT        0x08
  1112. #define CLIP_TEXTURE_BIT    0x10
  1113.  
  1114.  
  1115.  
  1116. /*
  1117.  * Bitmasks to indicate which rasterization options are enabled (CC.RasterMask)
  1118.  */
  1119. #define ALPHATEST_BIT        0x001    /* Alpha-test pixels */
  1120. #define BLEND_BIT        0x002    /* Blend pixels */
  1121. #define DEPTH_BIT        0x004    /* Depth-test pixels */
  1122. #define FOG_BIT            0x008    /* Per-pixel fog */
  1123. #define LOGIC_OP_BIT        0x010    /* Apply logic op in software */
  1124. #define SCISSOR_BIT        0x020    /* Scissor pixels */
  1125. #define STENCIL_BIT        0x040    /* Stencil pixels */
  1126. #define MASKING_BIT        0x080    /* Do glColorMask() or glIndexMask() */
  1127. #define ALPHABUF_BIT        0x100    /* Using software alpha buffer */
  1128. #define WINCLIP_BIT        0x200    /* Clip pixels/primitives to window */
  1129. #define FRONT_AND_BACK_BIT    0x400    /* Write to front and back buffers */
  1130. #define NO_DRAW_BIT        0x800    /* Don't write any pixels */
  1131.  
  1132.  
  1133. /*
  1134.  * Bits to indicate what state has to be updated (CC.NewState)
  1135.  */
  1136. #define NEW_ALL        0x7
  1137. #define NEW_LIGHTING    0x1
  1138. #define NEW_RASTER_OPS    0x2
  1139. #define NEW_TEXTURING    0x4
  1140.  
  1141.  
  1142. /*
  1143.  * The library context: 
  1144.  */
  1145.  
  1146. struct gl_context {
  1147.     /* State possibly shared with other contexts in the address space */
  1148.     struct gl_shared_state *Shared;
  1149.  
  1150.     /* API function pointer tables */
  1151.     struct api_function_table API;        /* For api.c */
  1152.     struct api_function_table Save;        /* Display list save funcs */
  1153.     struct api_function_table Exec;        /* Execute funcs */
  1154.  
  1155.         GLvisual *Visual;
  1156.         GLframebuffer *Buffer;
  1157.  
  1158.     /* Driver function pointer table */
  1159.     struct dd_function_table Driver;
  1160.  
  1161.     /* Opaque handle for the device driver context */
  1162.     void *DriverCtx;
  1163.  
  1164.     /* Modelview matrix and stack */
  1165.     GLfloat ModelViewMatrix[16];
  1166.     GLfloat ModelViewInv[16];    /* Inverse of ModelViewMatrix */
  1167.     GLboolean ModelViewInvValid;    /* Is the inverse matrix now valid? */
  1168.     GLuint ModelViewStackDepth;
  1169.     GLfloat ModelViewStack[MAX_MODELVIEW_STACK_DEPTH][16];
  1170.  
  1171.     /* Projection matrix and stack */
  1172.     GLfloat ProjectionMatrix[16];
  1173.     GLuint ProjectionStackDepth;
  1174.     GLfloat ProjectionStack[MAX_PROJECTION_STACK_DEPTH][16];
  1175.  
  1176.     /* Texture matrix and stack */
  1177.     GLfloat TextureMatrix[16];
  1178.         GLboolean IdentityTexMat;    /* Is TextureMatrix==Identity? */
  1179.     GLuint TextureStackDepth;
  1180.     GLfloat TextureStack[MAX_TEXTURE_STACK_DEPTH][16];
  1181.  
  1182.     /* Display lists */
  1183.     GLuint CallDepth;    /* Current recursion calling depth */
  1184.     GLboolean ExecuteFlag;    /* Execute GL commands? */
  1185.     GLboolean CompileFlag;    /* Compile GL commands into display list? */
  1186.  
  1187.     /* Renderer attribute stack */
  1188.     GLuint AttribStackDepth;
  1189.     struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
  1190.  
  1191.     /* Renderer attribute groups */
  1192.     struct gl_accum_attrib        Accum;
  1193.     struct gl_colorbuffer_attrib    Color;
  1194.     struct gl_current_attrib    Current;
  1195.     struct gl_depthbuffer_attrib    Depth;
  1196.     struct gl_eval_attrib        Eval;
  1197.     struct gl_fog_attrib        Fog;
  1198.     struct gl_hint_attrib        Hint;
  1199.     struct gl_light_attrib        Light;
  1200.     struct gl_line_attrib        Line;
  1201.     struct gl_list_attrib        List;
  1202.     struct gl_pixel_attrib        Pixel;
  1203.     struct gl_point_attrib        Point;
  1204.     struct gl_polygon_attrib    Polygon;
  1205.     GLuint PolygonStipple[32];
  1206.     struct gl_scissor_attrib    Scissor;
  1207.     struct gl_stencil_attrib    Stencil;
  1208.     struct gl_texture_attrib    Texture;
  1209.     struct gl_transform_attrib    Transform;
  1210.     struct gl_viewport_attrib    Viewport;
  1211.  
  1212.     /* Client attribute stack */
  1213.     GLuint ClientAttribStackDepth;
  1214.     struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
  1215.     /* Client attribute groups */
  1216.     struct gl_array_attrib        Array;    /* Vertex arrays */
  1217.     struct gl_pixelstore_attrib    Pack;    /* Pixel packing */
  1218.     struct gl_pixelstore_attrib    Unpack;    /* Pixel unpacking */
  1219.  
  1220.     struct gl_evaluators EvalMap;    /* All evaluators */
  1221.     struct gl_feedback Feedback;    /* Feedback */
  1222.     struct gl_selection Select;    /* Selection */
  1223.  
  1224.     GLenum ErrorValue;        /* Last error code */
  1225.  
  1226.     /* Miscellaneous */
  1227.         GLuint NewState;        /* bitwise OR of NEW_* flags */
  1228.     GLenum RenderMode;    /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
  1229.     GLenum Primitive;    /* glBegin primitive or GL_BITMAP */
  1230.     GLuint StippleCounter;    /* Line stipple counter */
  1231.     GLuint ClipMask;    /* OR of CLIP_* values from above */
  1232.     GLuint RasterMask;    /* OR of rasterization flags */
  1233.     GLuint LightTwoSide;    /* Compute two-sided lighting? */
  1234.     GLboolean DirectTriangles;/* Directly call (*ctx->TriangleFunc) ? */
  1235.     GLfloat PolygonZoffset;    /* Z offset for GL_FILL polygons */
  1236.     GLfloat LineZoffset;    /* Z offset for GL_LINE polygons */
  1237.     GLfloat PointZoffset;    /* Z offset for GL_POINT polygons */
  1238.     GLboolean NeedNormals;     /* Are vertex normal vectors needed? */
  1239.         GLboolean FastDrawPixels;/* Use optimized glDrawPixels? */
  1240.         GLboolean MutablePixels; /* Can rasterization change pixel's color? */
  1241.         GLboolean MonoPixels;    /* Are all pixels likely to be same color? */
  1242.         GLint ColorShift;    /* If flat shading ColorShift=0 */
  1243.                 /* If smooth shading ColorShift=FIXED_SHIFT */
  1244.  
  1245.     /* Current Primitive functions */
  1246.         points_func PointsFunc;
  1247.         line_func LineFunc;
  1248. #ifdef MONDELLO
  1249.         line_func LineFunc2;
  1250. #endif
  1251.         polygon_func PolygonFunc;
  1252.         polygon_func AuxPolygonFunc;
  1253.         triangle_func TriangleFunc;
  1254.  
  1255.     /* The vertex buffer being used by this context */
  1256.     struct vertex_buffer* VB;
  1257.  
  1258.     /* The pixel buffer being used by this context */
  1259.     struct pixel_buffer* PB;
  1260.  
  1261. #ifdef PROFILE
  1262.         /* Performance measurements */
  1263.         GLuint BeginEndCount;    /* number of glBegin/glEnd pairs */
  1264.         GLdouble BeginEndTime;    /* seconds spent between glBegin/glEnd */
  1265.         GLuint VertexCount;    /* number of vertices processed */
  1266.         GLdouble VertexTime;    /* total time in seconds */
  1267.         GLuint PointCount;    /* number of points rendered */
  1268.         GLdouble PointTime;    /* total time in seconds */
  1269.         GLuint LineCount;    /* number of lines rendered */
  1270.         GLdouble LineTime;    /* total time in seconds */
  1271.         GLuint PolygonCount;    /* number of polygons rendered */
  1272.         GLdouble PolygonTime;    /* total time in seconds */
  1273.         GLuint ClearCount;    /* number of glClear calls */
  1274.         GLdouble ClearTime;    /* seconds spent in glClear */
  1275.         GLuint SwapCount;    /* number of swap-buffer calls */
  1276.         GLdouble SwapTime;    /* seconds spent in swap-buffers */
  1277. #endif
  1278.  
  1279.         /* For debugging/development only */
  1280.         GLboolean NoRaster;
  1281. };
  1282.  
  1283.  
  1284. #endif
  1285.